Skip to content

feat(core/inlines): add !!type disambiguation for IDL links#5240

Open
marcoscaceres wants to merge 5 commits intomainfrom
fix/4290-event-linking
Open

feat(core/inlines): add !!type disambiguation for IDL links#5240
marcoscaceres wants to merge 5 commits intomainfrom
fix/4290-event-linking

Conversation

@marcoscaceres
Copy link
Copy Markdown
Contributor

@marcoscaceres marcoscaceres commented May 4, 2026

Closes #4290

Adds Bikeshed-compatible !!type syntax for disambiguating IDL links in {{ }} shorthand. This lets authors force a specific IDL type when the default resolution picks the wrong definition (e.g., an attribute named change vs the change event).

Syntax: {{ Interface/member!!type }}

Example: {{ ScreenOrientation/change!!event }} forces resolution as an event, not an attribute.

Also fixes [= term =] links to properly resolve data-dfn-type="event" definitions (the original bug).

Invalid type hints produce a warning and fall back to default resolution behavior.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates ReSpec’s inline link micro-syntax ([= ... =]) so it can resolve local definitions that are typed as events (data-dfn-type="event"), addressing #4290 where event-type definitions weren’t being linked.

Changes:

  • Extend [= ... =] generated anchors to include event in data-link-type so core/link-to-dfn can match event dfns.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/core/inlines.js Outdated
@marcoscaceres
Copy link
Copy Markdown
Contributor Author

@copilot Can you confirm all your feedback has been addressed? Can you fix anything that was not addressed?

Copy link
Copy Markdown
Contributor

Copilot AI commented May 4, 2026

@copilot Can you confirm all your feedback has been addressed? Can you fix anything that was not addressed?

Yes, all feedback has been addressed:

  • The fix in src/core/inlines.js adds event to the data-link-type attribute so [= =] can resolve to data-dfn-type="event" definitions.
  • A regression test was added (commit 612b794) in tests/spec/core/inlines-spec.js that defines <dfn data-dfn-type="event">orientationchange</dfn> and asserts [= orientationchange =] resolves to #dfn-orientationchange.

@marcoscaceres marcoscaceres marked this pull request as ready for review May 5, 2026 04:13
@marcoscaceres marcoscaceres requested a review from sidvishnoi May 5, 2026 04:13
Copy link
Copy Markdown
Member

@sidvishnoi sidvishnoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the {{ }} syntax is better suited for events. Any reason for not going with that?

Adds Bikeshed-compatible !!type suffix to {{ }} IDL inline syntax.
When present, the type hint overrides the default fallback type list,
allowing authors to disambiguate between IDL members that share a name
(e.g., an attribute and an event on the same interface).

Example: {{ PermissionStatus/change!!event }} links specifically to the
"change" event, not the "onchange" attribute.

Reverts the [= =] approach for event linking in favor of this general
type disambiguation mechanism.

Closes #4290
@marcoscaceres
Copy link
Copy Markdown
Contributor Author

Reworked to use Bikeshed-compatible !!type disambiguation syntax:

{{ PermissionStatus/change!!event }}

This is a general mechanism (not event-specific) that works like Bikeshed's !!type suffix. When the type hint is present, it overrides the default fallback types. When absent, existing behavior is unchanged.

The [= =] approach is reverted. Events are now IDL things, linked via {{ }} as you suggested.

@marcoscaceres marcoscaceres changed the title fix(core/inlines): allow [= =] to link event-type definitions feat(core/inlines): add !!type disambiguation for IDL links May 7, 2026
@marcoscaceres
Copy link
Copy Markdown
Contributor Author

@copilot Can you confirm all your feedback has been addressed? Can you fix anything that was not addressed?

Copilot AI and others added 2 commits May 8, 2026 17:20
… fix JSDoc

- Add `showWarning` to imports
- Define `validTypeHints` set for the `!!type` disambiguation suffix
- Fix `parseInlineIDL` JSDoc: `@returns {InlineIdl[]}` → `@returns {{ tokens: InlineIdl[], typeHint: string }}`
- Validate `typeHint` in `idlStringToHtml`: warn and fall back to default when type is unknown
- Add test for invalid `!!type` hint warning behavior

Agent-Logs-Url: https://github.com/speced/respec/sessions/e4d82a3b-b17c-4efd-bbdf-5170f1489756

Co-authored-by: marcoscaceres <870154+marcoscaceres@users.noreply.github.com>
Use concise common-type hint instead of listing all 20 valid types.

Agent-Logs-Url: https://github.com/speced/respec/sessions/e4d82a3b-b17c-4efd-bbdf-5170f1489756

Co-authored-by: marcoscaceres <870154+marcoscaceres@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 8, 2026

@copilot Can you confirm all your feedback has been addressed? Can you fix anything that was not addressed?

All prior reviewer feedback was addressed. Additionally, I found and fixed two issues in the reworked implementation:

  1. JSDoc mismatch: parseInlineIDL was documented as @returns {InlineIdl[]} but actually returns { tokens: InlineIdl[], typeHint: string } — fixed in 9ead023.

  2. Missing warning for invalid !!type hints: The PR description stated "Invalid type hints produce a warning and fall back to default resolution behavior" but the code didn't implement this. Added a validTypeHints set and a showWarning call when an unrecognized type is used, along with a regression test — dfcda62.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Events are for things, but ReSpec doesn't link them

4 participants